package com.clkj.xiuzheng.dao.shangcheng;

import com.clkj.xiuzheng.pojo.shangcheng.VipLevel;
import com.clkj.xiuzheng.pojo.shangcheng.VipLevelNum;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@Repository
public interface ScVipLevelNumMapper extends Mapper<VipLevelNum> {
    @Select("select level_name from t_xz_vipLevelNum where vip_level_number = #{level} and company_id = #{companyId}")
    String setNameByLevel(@Param("level") Integer level, @Param("companyId") Integer companyId);

    //a.level_id =  #{levelId} and
    @Select("select a.level_name,b.* from t_xz_vipLevelNum a left join t_xz_vipLevel b on a.level_id = b.level_id where  b.level_status = 1")
    List<VipLevel> listVipLevelByUser();

    @Select("select top 1 * from t_xz_vipLevelNum where next_score < #{score} order by vip_level_number asc")
    VipLevelNum listCurr(@Param("score")Integer score);

    @Delete("DELETE FROM t_xz_vipLevelNum WHERE level_id = #{levelId} ")
    void deleteScvipLevelNum(Integer levelId);

    @Update("UPDATE t_xz_vipLevelNum SET level_name = #{levelName},next_score = #{nextScore},company_id =#{companyId},vip_level_number=#{vipLevelNumber}  WHERE level_id = #{levelId}")
    void updateEditVipLevelNum(VipLevelNum vipLevelNum);
}
